package npr;


import processing.core.*;

import javax.media.opengl.*;
import com.sun.opengl.util.*;
import java.util.LinkedList;
import java.util.ListIterator;
import javax.media.opengl.*;
import com.sun.opengl.util.*;

/** 
 * ObjectSpaceLines is the superclass for all object space line drawing algorithms and is not to be instantiated directly.
 */
public class ObjectSpaceLines extends Lines{


    /** The red value of the line color for hidden lines. Ranges from 0.0 to 1.0. */
    protected float hiddenRed= 0.8f;
    /** The green value of the line color for hidden lines. Ranges from 0.0 to 1.0. */
    protected float hiddenGreen= 0.8f;
    /** The blue value of the line color for hidden lines. Ranges from 0.0 to 1.0. */
    protected float hiddenBlue= 0.8f;
    /** The alpha value of the line color for hidden lines. Ranges from 0.0 to 1.0. */
    protected float hiddenAlpha= 0.8f;
    /** The line width */
    protected float hiddenWidth;
    /**
     * Controls how many lines are detected.
     */
    protected float threshold= 0.5f;
    /**
     * Specifies whether hidden lines should be drawn.
     */
    protected boolean drawHiddenLines= false;

    /** 
     * Creates a SmoothRidges object.
     */
    public ObjectSpaceLines(){

	hiddenWidth= 0.6f*width;
    }


    /**
     * Sets the line width for hidden lines.
     *
     *
     * @param width line width.
     */
    public void setHiddenWidth(float width){
	this.hiddenWidth= width;
    }


    /**
     * Sets the line color for hidden lines to a gray value. Alpha will be set to 255.
     * 
     * @param gray the gray value between 0 and 255.
     */ 
    public void setHiddenColor(int gray){
	setHiddenColor(gray, gray, gray, 255);
    }

    /**
     * Sets the line color for hidden lines to a gray value and the alpha to specified alpha value.
     * 
     * @param gray the gray value between 0 and 255.
     * @param alpha the alpha value between 0 and 255.
     */

    public void setHiddenColor(int gray, int alpha){
	setHiddenColor(gray, gray, gray, alpha);
    }


    /**
     * Sets the line color for hidden lines to specified RGB values. Alpha will be set to 255.
     * 
     * @param r the red value between 0 and 255
     * @param g the green value between 0 and 255
     * @param b the blue value between 0 and 255
     */

    public void setHiddenColor(int r, int g, int b){
	setHiddenColor(r, g, b, 255);
    }


    /**
     * Sets the line color for hidden lines to specified RGBA value
     * 
     * @param r the red value between 0 and 255
     * @param g the green value between 0 and 255
     * @param b the blue value between 0 and 255
     * @param a the alpha value between 0 and 255
     */

    public void setHiddenColor(int r, int g, int b, int a) {
	setHiddenColor((float)r/255.0f, (float)g/255.0f, (float)b/255.0f, (float)a/255.0f);
    }


    /**
     * Sets the line color for hidden lines to a gray value. Alpha will be set to 1.0.
     * 
     * @param gray the gray value between 0.0 and 1.0
     */

    public void setHiddenColor(float gray) {
	setHiddenColor(gray, gray, gray, 1.0f);
    }


    /**
     * Sets the line color for hidden lines to a gray value and the alpha to specified alpha value.
     * 
     * @param gray the gray value between 0.0 and 1.0
     * @param alpha the alpha value between 0.0 and 1.0
     */

    public void setHiddenColor(float gray, float alpha) {
	setHiddenColor(gray, gray, gray, alpha);
    }


    /**
     * Sets the line color for hidden lines to specified RGB values. Alpha will be set to 1.0.
     * 
     * @param r the red value between 0.0 and 1.0
     * @param g the green value between 0.0 and 1.0
     * @param b the blue value between 0.0 and 1.0
     */

    public void setHiddenColor(float r, float g, float b) {
	setHiddenColor(r, g, b, 1.0f);
    }


    /**
     * Sets the line color for hidden lines to specified RGBA value
     * 
     * @param r the red value between 0.0 and 1.0
     * @param g the green value between 0.0 and 1.0
     * @param b the blue value between 0.0 and 1.0
     * @param a the alpha value between 0.0 and 1.0
     */
    
    public void setHiddenColor(float r, float g, float b, float a) {
	hiddenRed= r; 
	hiddenBlue= b; 
	hiddenGreen= g; 
	hiddenAlpha= a;
    }

    /**
     * Controls how many lines are detected.
     *
     * @threshold threshold
     */
    public void setThreshold(float threshold){
	
	this.threshold= threshold;
    }



    /**
     * Specifies whether hidden lines should be drawn.
     *
     * @param drawHiddenLines true if hidden lines are to be drawn, false if not.
     * The default is false.
     */
    public void drawHiddenLines(boolean drawHiddenLines){
	
	this.drawHiddenLines= drawHiddenLines;
    }

}